import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
// import 'element-plus/dist/index.css'
import 'element-plus/lib/theme-chalk/index.css';
import locale from "element-plus/lib/locale/lang/zh-cn";
import request from './utils/request'
import storage from './utils/storage'
import api from './api'
import store from './store'
import * as echarts from 'echarts';


console.log("环境变量=>",
  import.meta.env)
const app = createApp(App);
app.directive('has', {
  beforeMount: function (el, binding) {
    // 拿到当前用户的权限列表
    let actionList = storage.getItem('actionList');
    // 拿到自定义指令设置的值
    let value = binding.value;
    // 判断权限列表中有没有这个值
    let hasPermission = actionList.includes(value)
    // 没有移除
    if (!hasPermission) {
      el.style = 'display:none';
      setTimeout(() => {
        el.parentNode.removeChild(el);
      }, 0)
    }
  }
})
app.config.globalProperties.$request = request;
app.config.globalProperties.$api = api;
app.config.globalProperties.$echarts = echarts;
app.config.globalProperties.$storage = storage;
app.use(router).use(store).use(ElementPlus, { size: 'middle', locale }).mount('#app')